--[[
* 修正中了该buff的对象(buff拥有者)的生命上限
* [0] 属性计算的来源0=buff施法者, 1=buff拥有者
* [1] 类型 1 指定值，2 当前血量比例，3 最大血量比例，4 已消耗血量比例 5技能造成的伤害
* [2] 1=增加  2=减少
* [3] value (根据[1]参与计算)
*]]
---@class BuffEffect65 : BaseBuffEffect
BuffEffect65 = ClientFight.CreateClass("BuffEffect65", ClientFight.BaseBuffEffect)
local t = BuffEffect65
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    ClientFight.BaseBuffEffect.add(self, fight, buff);
    local addParameters = buffoverlaypParameters;-- false, action.getBuffId(), action.getBuffOverlay(), target, skill,result
    if (addParameters == nil) then
        addParameters = buffaddParameters;
    end
    if (addParameters == nil) then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBeanf_BuffEffectValue;
    if (buffEffectValue[2] == 5 and table.getn(addParameters) < 3) then
        return IBuffEffect.FAIL;
    end
    local fighter = buff.target;
    if (buffEffectValue[1] == 0) then
        fighter = buff.source;
    end
    local addValue = 0;
    if (buffEffectValue[2] == 5) then
        addValue = (addParameters[3]);
    elseif (buffEffectValue[2] == 1) then
        addValue = buffEffectValue[5];
    elseif (buffEffectValue[2] == 2) then
        addValue = (long)(fighterhp * MathUtil.toRatio(buffEffectValue[5]));
    elseif (buffEffectValue[2] == 3) then
        addValue = (long)(FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.HP) * MathUtil.toRatio(buffEffectValue[5]));
    elseif (buffEffectValue[2] == 4) then
        addValue = (long)((FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.HP) - fighterhp) * MathUtil.toRatio(buffEffectValue[5]));
    end
    if (addValue < 1) then
        return IBuffEffect.FAIL;
    end
    addValue = addValue * (buffEffectValue[3] == 1 and 1 or -1);

    local oldValue = buff.attributes.attributes[FighterAttributeEnum.HP.id] or  0;
    buff.attributes.attributes[FighterAttributeEnum.HP.id] = addValue + oldValue;

    local logAddValue = addValue;
    SkillRoleMgr.savePathFile("[" + fightframe + "][EFFECT]Fighter " + buff.targetfighterId + " Buff:"
            + buffmodelId + " buff 导致生命上限发生变化: " + logAddValue);

    return ClientFight.BaseBuffEffect.add(self, fight, buff);
end

t.New()